package com.iptv.grape.bu.imp;

import android.view.KeyEvent;

import com.iptv.grape.BaseActivity;
import com.iptv.grape.bu.AppState;
import com.iptv.grape.bu.GrapeContext;
import com.iptv.grape.bu.IKeyEventPorc;
import com.iptv.grape.event.EventArgs;
import com.iptv.grape.event.msg.BackVodFullScreenMsg;
import com.iptv.grape.util.WebViewUtils;
import com.iptv.grape.video.XMediaPlayer;

import org.greenrobot.eventbus.EventBus;
// 点播模式下 退出全屏
@AppState(isShowLiveMenu = false,keyVals = {4},curPlayType = "Vod")
public class QuitVodFullScreen implements IKeyEventPorc {

    @Override
    public void onKeyDownEvent(BaseActivity context, XMediaPlayer mediaPlayer, GrapeContext grapeContext, KeyEvent event) {
        //context.hidePause();
        if(!mediaPlayer.isPlaying()) {
            mediaPlayer.start();
        }
        mediaPlayer.quitFullScreen();
        grapeContext.setFullScreen(false);
        grapeContext.setFocus(false);
        //EventBus.getDefault().post(new EventArgs("QuitFullScreenProc", "JsEvent"));

        WebViewUtils.sentKeyMessageToWebView(new BackVodFullScreenMsg(), context.getBridgeWebView());
    }
}
